<template>
    <div class="Authenticationmanagement">
        <div class="Authen-titke">
            <i></i>
            <h2>认证中心</h2>
            <i></i>
        </div>
        <div class="Authen-con">
            <ul>
                <li @click="goAuth()">
                    <span v-if="Iscertification1 == 1" style="color:#BCBBBB">已认证</span>
                    <span v-if="Iscertification1 == 2" style="color:#BCBBBB">审核中</span>
                    <span v-if="Iscertification1 == 3" style="color:#BCBBBB">已拒绝</span>
                    <span v-if="Iscertification1 == 0">去认证</span>
                </li>
                <li @click="goAuthindet()">
                    <span v-if="Iscertification2 == 1" style="color:#BCBBBB">已认证</span>
                    <span v-if="Iscertification2 == 2" style="color:#BCBBBB">审核中</span>
                    <span v-if="Iscertification2 == 3" style="color:#BCBBBB">已拒绝</span>
                    <span v-if="Iscertification2 == 0">去认证</span>
                </li>
                <li @click="goHelp()">
                    <span v-if="Iscertification3 == 1" style="color:#BCBBBB">审核中</span>
                    <span v-if="Iscertification3 == 2" style="color:#BCBBBB">审核通过</span>
                    <span v-if="Iscertification3 == 3" style="color:#BCBBBB">审核拒绝</span>
                    <span v-if="Iscertification3 == 4" style="color:#BCBBBB">已被注销</span>
                    <span v-if="Iscertification3 == 0" >去认证</span>
                </li>
                <li @click="gosijiao()">
                    <span v-if="Iscertification4 == 1" style="color:#BCBBBB">审核中</span>
                    <span v-if="Iscertification4 == 2" style="color:#BCBBBB">审核通过</span>
                    <span v-if="Iscertification4 == 3" style="color:#BCBBBB">审核拒绝</span>
                    <span v-if="Iscertification4 == 4" style="color:#BCBBBB">已被注销</span>
                    <span v-else>立即入驻</span>
                </li>
                <li @click="gojigou()">
                    <span v-if="Iscertification5 == 1" style="color:#BCBBBB">审核中</span>
                    <span v-if="Iscertification5 == 2" style="color:#BCBBBB">审核通过</span>
                    <span v-if="Iscertification5 == 3" style="color:#BCBBBB">审核拒绝</span>
                    <span v-if="Iscertification5 == 4" style="color:#BCBBBB">已被注销</span>
                    <span v-if="Iscertification5 == 5" style="color:#BCBBBB">已被冻结</span>
                    <span v-else>立即入驻</span>
                </li>
            </ul>
        </div>
    </div>
</template>
<script>
export default {
    name:'Authenticationmanagement',
    data(){
        return{
            Iscertification1:0,
            Iscertification2:0,
            Iscertification3:0,
            Iscertification4:0,
            Iscertification5:0,
            tabIndex:localStorage.getItem('tablesListindex'),
            userinfo:JSON.parse(localStorage.getItem('userinfo')),
        }
    },
    mounted(){
        this.checkIscertification()
    },
    methods:{
        checkIscertification(){
            this.Iscertification1 = this.userinfo.overseas_auth
            this.user_id = this.userinfo.user_id
            // this.user_id = 9601//9099
            this.$axios({//身份认证状态查询
                method:'get',
                url:'http://101.37.66.151:8768/eg-api/user/overseasIdentity/query?user_id='+this.user_id,
            }).then((res) =>{
                console.log(res.data.data)
                this.Iscertification2 = res.data.data[0].status
            }).catch((error) =>{
                console.log(error)
            })

            this.$axios({//机构认证状态查询
                method:'get',
                url:'http://101.37.66.151:8768/eg-api/user/mastermechanism/queryMechanismListPage?user_id='+this.user_id,
            }).then((res) =>{
                //状态1 正在审核 , 2 审核通过 3 审核拒绝 4 注销 5 冻结
                console.log(res.data.data)
                if(res.data.data.length == 0){
                    this.Iscertification5 = 0
                }else{
                    res.data.data.map(item=>{
                        this.Iscertification5 = item.status
                    })
                }
                
            }).catch((error) =>{
                console.log(error)
            })

            this.$axios({//实名认证状态查询
                method:'get',
                url:'http://101.37.66.151:8768/eg-api/user/userIdentity/query?user_id='+this.user_id,
            }).then((res) =>{
                //认证状态 状态 1 同意 2 等待审核 3 拒绝
                console.log(res.data.data)
                this.Iscertification1 = res.data.data[0].status
            }).catch((error) =>{
                console.log(error)
            })


            this.$axios({//私教以及助学师状态查询
                method:'get',
                url:'http://101.37.66.151:8768/eg-api/user/masterInfo/query?user_id='+this.user_id,
            }).then((res) =>{
                console.log(res.data.data,'私教以及助学师信息')
                //状态1 正在审核 , 2 审核通过 3 审核拒绝 4 注销
                res.data.data.map(item=>{
                    if(item.type == 'private_education'){ //私教认证状态查询
                        this.Iscertification4 = item.status
                    }
                    if(item.status == 2){
                        this.Iscertification3 = 2
                        return
                    }
                    if(item.status == 1){
                        this.Iscertification3 = 1
                        return
                    }
                    if(item.status == 3){
                        this.Iscertification3 = 3
                        return
                    }
                    if(item.status == 4){
                        this.Iscertification3 = 4
                        return
                    }
                })
                // if(res.data.data[0].status == 1){
                //     this.Iscertification2 = true
                // }else{
                //     this.Iscertification2 = false
                // }
            }).catch((error) =>{
                console.log(error)
            })
        },
        goAuth(){
            if(this.Iscertification1 == 1){
                this.$message('已认证，无法修改')
            }else if(this.Iscertification1 == 2){
                this.$message('正在审核中，请耐心等待')
            }else if(this.Iscertification1 == 3){
                this.$message('已经被拒绝，请重新提交资料')
                if(this.tabIndex == 1){
                    this.$router.push({
                        path:'/views/Teachingcenters/Realnameauthentication'
                    })
                }else{
                    this.$router.push({
                        path:'/views/Learningcenter/Realnameauthentication'
                    })
                }
            }else{
                if(this.tabIndex == 1){
                    this.$router.push({
                        path:'/views/Teachingcenters/Realnameauthentication'
                    })
                }else{
                    this.$router.push({
                        path:'/views/Learningcenter/Realnameauthentication'
                    })
                }
            }
            
        },
        goAuthindet(){
            //1 已认证, 2 审核中, 3 已拒绝
            if(this.Iscertification2 == 1){
                this.$message('已经认证无法修改')
            }else if (this.Iscertification2 == 2){
                this.$message('正在审核中，请耐心等待')
            }else if (this.Iscertification2 == 3){
                this.$message('已经被拒绝，请重新提交资料')
                if(this.tabIndex == 1){
                    this.$router.push({
                        path:'/views/Teachingcenters/Theidentityauthentication'
                    })
                }else{
                    this.$router.push({
                        path:'/views/Learningcenter/Theidentityauthentication'
                    })
                }  
            }else {
                if(this.tabIndex == 1){
                    this.$router.push({
                        path:'/views/Teachingcenters/Theidentityauthentication'
                    })
                }else{
                    this.$router.push({
                        path:'/views/Learningcenter/Theidentityauthentication'
                    })
                }  
            }
             
        },
        goHelp(){
             //状态1 正在审核 , 2 审核通过 3 审核拒绝 4 注销
            //  this.Iscertification3 = 3
            if(this.Iscertification3 == 1){
                this.$message('正在审核，请耐心等待结果')
            }else if (this.Iscertification3 == 2){
                this.$message('已经审核通过，不可修改,请前往教学中心查看')
            }else if (this.Iscertification3 == 3){
                this.$message('审核拒绝，请重新提交')
                if(this.tabIndex == 1){
                    this.$router.push({
                        path:'/views/Teachingcenters/Studentteacher'
                    })
                }else{
                    this.$router.push({
                        path:'/views/Learningcenter/Studentteacher'
                    })
                }  
            }else if (this.Iscertification3 == 4){
                this.$message('已被注销，请联系管理人员')
            }else{
                if(this.tabIndex == 1){
                    this.$router.push({
                        path:'/views/Teachingcenters/Studentteacher'
                    })
                }else{
                    this.$router.push({
                        path:'/views/Learningcenter/Studentteacher'
                    })
                }  
            }
        },
        gosijiao(){
            //状态1 正在审核 , 2 审核通过 3 审核拒绝 4 注销
            if(this.Iscertification4 == 1){
                this.$message('正在审核，请耐心等待结果')
            }else if (this.Iscertification4 == 2){
                this.$message('已经审核通过，不可修改,请前往教学中心查看')
            }else if (this.Iscertification4 == 3){
                this.$message('审核拒绝，请重新提交')
                if(this.tabIndex == 1){
                    this.$router.push({
                        path:'/views/Teachingcenters/privateEducationCertification'
                    })
                }else{
                    this.$router.push({
                        path:'/views/Learningcenter/privateEducationCertification'
                    })
                } 
            }else if (this.Iscertification4 == 4){
                this.$message('已被注销，请联系管理人员')
            }else{
                if(this.tabIndex == 1){
                    this.$router.push({
                        path:'/views/Teachingcenters/privateEducationCertification'
                    })
                }else{
                    this.$router.push({
                        path:'/views/Learningcenter/privateEducationCertification'
                    })
                } 
            }
            
        },
        gojigou(){
            //状态1 正在审核 , 2 审核通过 3 审核拒绝 4 注销 5 冻结
            if(this.Iscertification5 == 1){
                this.$message('正在审核，请等待结果')
            }else if (this.Iscertification5 == 2){
                this.$message('已经审核通过，不可修改，请前往机构管理中心查看')
            }else if (this.Iscertification5 == 3){
                this.$message('审核拒绝，请重新提交')
                if(this.tabIndex == 1){
                    this.$router.push({
                        path:'/views/Teachingcenters/agencyCertification'
                    })
                }else{
                    this.$router.push({
                        path:'/views/Learningcenter/agencyCertification'
                    })
                } 
            }else if (this.Iscertification5 == 4){
                this.$message('已被注销，请联系管理人员')
            }else if (this.Iscertification5 == 5){
                this.$message('已被冻结，请联系管理人员')
            }else{
                if(this.tabIndex == 1){
                    this.$router.push({
                        path:'/views/Teachingcenters/agencyCertification'
                    })
                }else{
                    this.$router.push({
                        path:'/views/Learningcenter/agencyCertification'
                    })
                } 
            }
            
        },
    }
}
</script>
<style lang="less" scoped>
    .Authenticationmanagement{
        position: relative;
        width: 90%;
        background: #ffffff;
        // height: 600px;
        padding-bottom: 100px;
        border-radius: 20px;
    }
    .Authen-titke{
        display: flex;
        width: 100%;
        height: 100px;
        align-items: center;
        justify-content: center;
        color: #30B9BA;
        font-size: 24px;
        padding-top: 30px;
        i{
            width: 6%;
            height: 100px;
            background-image: url('/images/矩形 33@2x.png');
            background-repeat: no-repeat;
            background-position-y: 50%;
        }
        h2{
            width: 30%;
            text-align: center;
        }
    }
    .Authen-con{
        position: relative;
        width: 90%;
        margin: 0 auto;
        ul{
            display: flex;
            list-style: none;
            width: 100%;
            justify-content: space-between;
            padding: 0%;
            flex-wrap: wrap;
            li{
                width: 28%;
                height: 343px;
                background-size: 100% 100%;
                background-repeat: no-repeat;
                margin-top: 30px;
                cursor: pointer;
                &:nth-child(2){
                    background-image: url('/images/二@2x.png');
                }
                &:nth-child(3){
                    background-image: url('/images/三@2x.png');
                }
                &:nth-child(4){
                    background-image: url('/images/入驻私教@2x.png');
                }
                span{
                    display: block;
                    text-align: center;
                    margin: 0 auto;
                    width: 60%;
                    height: 40px;
                    line-height: 40px;
                    border:1px solid rgba(45,199,200,1);
                    border-radius:20px;
                    color: #30B9BA;
                    margin-top: 260px;
                }
            }
            
        }
    }
    .Authen-con>ul::after{
        content: '';
        width: 28%;
    }
    .Authen-con>ul>li:first-child{
        background-image: url('/images/一@2x.png');
    }
    .Authen-con>ul>li:last-child{
        background-image: url('/images/入驻机构@2x.png');
    }
</style>